/**
 * 
 */
package org.sishoras.logic;

import java.util.List;

import org.sishoras.dao.DAOFactory;
import org.sishoras.interceptors.DAOInterceptor;
import org.sishoras.modelo.Disciplina;
import org.sishoras.modelo.Horario;
import org.sishoras.modelo.OcorrenciaDisciplina;
import org.sishoras.modelo.Professor;
import org.vraptor.annotations.Component;
import org.vraptor.annotations.InterceptedBy;

/**
 * This class is part of the SisHoras project	
 * Creation:  30/12/2008 20:33:02
 * TODO
 * 
 * @author Walker Rabelo
 * 
 */
@Component
@InterceptedBy(DAOInterceptor.class)
public class OcorrenciaDisciplinaLogic {

	private final DAOFactory daoFactory;
	
	private OcorrenciaDisciplina ocorrenciaDisciplina;	
	private List<OcorrenciaDisciplina> ocorrenciaDisciplinas;
	
	public OcorrenciaDisciplinaLogic(DAOFactory factory) {
		// TODO Auto-generated constructor stub
		this.daoFactory = factory;
	}
	public void form(){
		
	}	
	public void editar(OcorrenciaDisciplina ocorrenciaDisciplina){
		this.ocorrenciaDisciplina = this.daoFactory.getOcorrenciaDisciplinaDao().carregar(ocorrenciaDisciplina.getId());
	}	
	public void armazena(OcorrenciaDisciplina ocorrenciaDisciplina){
		this.daoFactory.beginTransaction();
		this.daoFactory.getOcorrenciaDisciplinaDao().atualiza(ocorrenciaDisciplina);
		this.daoFactory.commit();
	}
	public void remove(OcorrenciaDisciplina ocorrenciaDisciplina){
		this.daoFactory.beginTransaction();
		this.daoFactory.getOcorrenciaDisciplinaDao().remover(ocorrenciaDisciplina);
		this.daoFactory.commit();
	}
	public void lista(){
		ocorrenciaDisciplinas = this.daoFactory.getOcorrenciaDisciplinaDao().getLista();
	}

	/**
	 * @return the ocorrenciaDisciplinas
	 */
	public List<OcorrenciaDisciplina> getOcorrenciaDisciplinas() {
		return ocorrenciaDisciplinas;
	}

	public OcorrenciaDisciplina getOcorrenciaDisciplina() {
		return ocorrenciaDisciplina;
	}
	/**
	 * @return the professores
	 */
	public List<Professor> getListaProfessores() {
		return this.daoFactory.getProfessorDao().getLista();
	}
	/**
	 * @return the disciplinas
	 */
	public List<Disciplina> getListaDisciplinas() {
		return this.daoFactory.getDisciplinaDao().getLista();
	}
	/**
	 * @return the horarios
	 */
	public List<Horario> getListaHorarios() {
		return this.daoFactory.getHorarioDao().getLista();
	}		
}
